<!-- TabBar 文章资讯 -->
<template>
	<view>
		
		
		<!-- <view class="my-tab-box">
			<my-tab ref="myTab" :list="tabList" @change="changeTab" :currentIndex="tabIndex" name="title"></my-tab>
		</view>
			 -->
		<view style="padding: 30rpx;margin-bottom: 80rpx;">
			<!-- <u-swiper
						  :list="Links"
						  @change="e => current = e.current"
						  :autoplay="true"
									:border-radius="30"
						   name="pic"
				  >
			</u-swiper> -->
			<view class="notice-item" @click="navTo('/pages/news/news')">
				<text >
					公告
				</text>
			</view>
			<view style="float: right;padding: 30rpx;">
				<text>当前积分：{{userinfo.score}}</text>
			</view>
			
		</view>
	
		
		<my-list ref="myList"
			:api="productList" :params="params" :transformRequestData="transformRequestData">>
			<template v-slot:card="{list}">
				<view class="product-list-wrapper">
					<e-chart :bottom="0" :list="list" :isList="false"
						:style="{paddingTop: 10 + 'rpx' }"></e-chart>
				</view>
			</template>
		</my-list>

		<view style="width: 1rpx;height: 150rpx;"></view>
	
	</view>
</template>

<script>
	import request from '@/common/request.js';
	import eChart from '@/components/echart';
	export default {
		components: {
			eChart
		},
		data() {
			return {
				tabIndex:1,
				userinfo:{
					score:0
				},
				tabId:14
			};
		},
		computed:{
			params(){
				return {
					cate_id: this.tabId,
					limit:10
				};
			}
		},
		mounted() {
			this.init();
		},
		filters: {
			
			formatDate(value) {
				if (value == undefined) {
					return;
				}
				// let date = new Date(value * 1000);
				let date = new Date(value);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d; //天补0
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h; //小时补0
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m; //分钟补0
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s; //秒补0
				// return y + '-' + MM + '-' + d; //年月日	 + ' ' + h + ':' + m
				return y + '-' + MM + '-' + d; //年月日时分秒
			}
		},
		methods: {
			init(){
				let user = uni.getStorageSync('userInfo');
				if(!user){
					uni.showToast({ title:'请先登录', icon: 'none' });
					setTimeout(()=>{
						uni.navigateTo({
							url:`/pages/public/login`
						})
					},1000)
					return ;
				}
				this.userinfo = user;
			},
			changeTab(e) {
				this.tabIndex = e.index;
			},
			transformRequestData(data) {
				
				return data.data.data.data;
			},
			productList(value) {
				
				let opts = {
					url: 'api/gashapons/pro',
					method: 'get'
				};
				const result =  request.httpRequest(opts, value);
				return result;
			},
			navTo(url){
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.borderBottom {
		border-bottom: 1px solid #f2f2f2;
	}
	
	.notice-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		border: 1px solid #f2f2f2;
		height: 150rpx;
		border-radius: 30rpx;
		background: #fff;
		font-size:40rpx;
	}
	
	
	// 暂无数据
	.centre {
		text-align: center;
		margin: 200rpx auto;
		font-size: 32rpx;
	
		image {
			width: 300rpx;
			border-radius: 50%;
			margin: 0 auto;
		}
	
		.tips {
			font-size: 24rpx;
			color: #999999;
			margin-top: 20rpx;
		}
		.btn {
			margin: 80rpx auto;
			width: 200rpx;
			border-radius: 32rpx;
			line-height: 64rpx;
			color: #ffffff;
			font-size: 26rpx;
			background: linear-gradient(270deg, #1cbbb4 0%, #0081ff 100%);
		}
	}
	.nav .cu-item.cur {
		font-weight: 600;
	}
</style>
